Skip to content

fix(regex): register provider and fix match/compile parity - #193

Merged
sspaink merged 1 commit into
open-policy-agent:mainfrom
sspaink:fix/register-regex-provider
Aug 10, 2026
Merged

fix(regex): register provider and fix match/compile parity#193
sspaink merged 1 commit into
open-policy-agent:mainfrom
sspaink:fix/register-regex-provider

Conversation

@sspaink

@sspaink sspaink commented Aug 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #192. The BuiltinProvider entry for opa-builtins-regex was commented out in its META-INF/services file, so none of the eight regex builtins were reachable for consumers. eval --capabilities-current goes from 123 to 131.

Registering it exposed two parity gaps the compliance fixtures had been skipping:

  • regex.match used Matcher.matches(), which requires the pattern to match the entire input. Go's regexp.MatchString searches instead, so regex.match("", "x") must be true and an unanchored pattern must match a substring.
  • An invalid pattern let Java's unchecked PatternSyntaxException escape and abort evaluation. OPA reports this as a builtin error, so the call is undefined by default and only aborts under strict-builtin-errors.

Adds RegexBuiltinsTest, including a ServiceLoader assertion. The module had no unit tests, and the ones elsewhere call impl classes directly, which is why an unreachable module still looked healthy. Eight of the ten new tests fail against the unfixed code.

Removes the eight regex entries from known-missing-builtins.txt (64 → 56).

The BuiltinProvider entry for opa-builtins-regex was commented out in
its META-INF/services file, so ServiceLoader never discovered it and
none of the eight regex builtins were reachable for consumers.

Registering it exposed two parity gaps the fixtures had been skipping:

  - regex.match used Matcher.matches(), which requires the pattern to
    match the entire input. Go's regexp.MatchString searches instead, so
    regex.match("", "x") must be true and an unanchored pattern must
    match a substring.

  - An invalid pattern let Java's unchecked PatternSyntaxException
    escape and abort evaluation. OPA reports this as a builtin error, so
    the call is undefined by default and only aborts under
    strict-builtin-errors. All six compile sites now go through a helper
    that converts it to BuiltinError.

Adds RegexBuiltinsTest, including a ServiceLoader assertion: the module
had no unit tests, and the existing ones elsewhere call impl classes
directly, which is why the registration gap went unnoticed. Eight of the
ten new tests fail against the unfixed code.

Removes the eight regex entries from known-missing-builtins.txt (64 -> 56).

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink requested a review from a team as a code owner August 10, 2026 19:46
@sspaink
sspaink merged commit 33f7b21 into open-policy-agent:main Aug 10, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant